//
//  AddView.m
//  UI11限时代码
//
//  Created by dllo on 15/11/25.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "AddView.h"

@interface AddView ()<UITextFieldDelegate>

@property (nonatomic, retain) UITapGestureRecognizer *tapImageGR;

@end

@implementation AddView

- (void)dealloc
{
    [_textF1 release];
    [_textF2 release];
    [_textF3 release];
    [_textF4 release];
    [_tapImageGR release];
    [_imageV release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews
{
    self.backgroundColor = [UIColor whiteColor];
    
    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(20, 50, 80, 150)];
    self.imageV.image = [UIImage imageNamed:@"image6.jpg"];
    self.imageV.userInteractionEnabled = YES;
    [self addSubview:self.imageV];
    [_imageV release];
    
    
    self.textF1 = [[UITextField alloc] initWithFrame:CGRectMake(120, 50, 80, 30)];
    self.textF1.placeholder = @"请输入姓名";
    self.textF1.borderStyle = UITextBorderStyleRoundedRect;
    self.textF1.clearButtonMode = UITextFieldViewModeAlways;
    self.textF1.delegate = self;
    [self addSubview:self.textF1];
    [_textF1 release];
    
    self.textF2 = [[UITextField alloc] initWithFrame:CGRectMake(120, 100, 50, 30)];
    self.textF2.placeholder = @"请输入性别";
    self.textF2.borderStyle = UITextBorderStyleRoundedRect;
    self.textF2.clearButtonMode = UITextFieldViewModeAlways;
    self.textF2.delegate = self;
    [self addSubview:self.textF2];
    [_textF2 release];
    
    self.textF3 = [[UITextField alloc] initWithFrame:CGRectMake(230, 100, 50, 30)];
    self.textF3.placeholder = @"请输入年龄";
    self.textF3.borderStyle = UITextBorderStyleRoundedRect;
    self.textF3.clearButtonMode = UITextFieldViewModeAlways;
    self.textF3.delegate = self;
    [self addSubview:self.textF3];
    [_textF3 release];
    
    self.textF4 = [[UITextField alloc] initWithFrame:CGRectMake(120, 170, 150, 30)];
    self.textF4.placeholder = @"请输入联系方式";
    self.textF4.borderStyle = UITextBorderStyleRoundedRect;
    self.textF4.clearButtonMode = UITextFieldViewModeAlways;
    self.textF4.delegate = self;
    [self addSubview:self.textF4];
    [_textF4 release];
    
    // 轻拍
    UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [self addGestureRecognizer:tapGR];
    [tapGR release];
    
    self.tapImageGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [self.imageV addGestureRecognizer:self.tapImageGR];
    [_tapImageGR release];
    
    
}

- (void)tapAction:(UITapGestureRecognizer *)sender
{
    [self endEditing:YES];
    if (sender == self.tapImageGR) {
        [self.delegate headerImageHandle];
    }
    
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return  YES;
}

@end
